package com.edu.exam.entity.assessment.scheme;

import com.edu.exam.enums.assessment.SchemeStatus;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 考核方案实体类
 * 所属模块：B-04 考核方案管理模块
 * 对应数据库表：assessment_scheme_management
 *
 * <p>考核方案是课程考核的总体设计和安排，包括考核目标、内容、方式、标准等要素，
 * 是教学考核工作的指导性文件。支持方案的全生命周期管理，从创建到归档的完整流程。</p>
 *
 * @author 系统生成
 * @version 2.0
 * @since 2025-11-09
 */
@Entity
@Table(name = "assessment_scheme_management")
@Data
@EqualsAndHashCode(callSuper = false)
@EntityListeners(AuditingEntityListener.class)
public class AssessmentSchemeManagement {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 方案编码，系统唯一标识
     */
    @Column(name = "code", nullable = false, unique = true, length = 50)
    private String code;

    /**
     * 方案名称
     */
    @Column(name = "name", nullable = false, length = 200)
    private String name;

    /**
     * 方案描述
     */
    @Column(name = "description", columnDefinition = "TEXT")
    private String description;

    /**
     * 关联课程ID
     */
    @Column(name = "course_id", nullable = false)
    private Long courseId;

    /**
     * 方案状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "status", nullable = false, length = 20)
    private SchemeStatus status;

    /**
     * 总分
     */
    @Column(name = "total_score")
    private Integer totalScore;

    /**
     * 及格分数
     */
    @Column(name = "pass_score")
    private Integer passScore;

    /**
     * 适用学期
     */
    @Column(name = "semester", length = 50)
    private String semester;

    /**
     * 适用年级
     */
    @Column(name = "grade_level", length = 50)
    private String gradeLevel;

    /**
     * 方案版本
     */
    @Column(name = "version", length = 20)
    private String version;

    /**
     * 生效时间
     */
    @Column(name = "effective_time")
    private LocalDateTime effectiveTime;

    /**
     * 失效时间
     */
    @Column(name = "expiry_time")
    private LocalDateTime expiryTime;

    /**
     * 发布时间
     */
    @Column(name = "publish_time")
    private LocalDateTime publishTime;

    /**
     * 备注
     */
    @Column(name = "remarks", length = 500)
    private String remarks;

    /**
     * 创建人ID
     */
    @Column(name = "creator_id", nullable = false)
    private Long creatorId;

    /**
     * 更新人ID
     */
    @Column(name = "updater_id")
    private Long updaterId;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "create_time", nullable = false, updatable = false)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @LastModifiedDate
    @Column(name = "update_time", nullable = false)
    private LocalDateTime updateTime;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

    /**
     * 删除时间
     */
    @Column(name = "deleted_time")
    private LocalDateTime deletedTime;

    /**
     * 删除人ID
     */
    @Column(name = "deleted_by")
    private Long deletedBy;

    // ===== 关联对象 =====

    /**
     * 考核项目列表
     */
    @OneToMany(mappedBy = "scheme", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<AssessmentSchemeItem> items;

    /**
     * 考核标准列表
     */
    @OneToMany(mappedBy = "scheme", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<AssessmentSchemeStandard> standards;

  
}
